package com.micai.springboot.controller;

import com.micai.springboot.dto.UserDto;
import com.micai.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 描述：
 * <p>
 * Author: 赵新国
 * Date: 2017/11/13 17:59
 */
@Controller
public class RegisterController {

    @Autowired
    private UserService userService;

    /**
     * 跳转到注册页面
     * @return
     */
    @RequestMapping("/register")
    public String register() {
        return "register";
    }

    @RequestMapping("/reg")
    public String reg(String account, String password) {
        UserDto bizDto = new UserDto();
        bizDto.setUserName(account);
        bizDto.setPassWord(password);
        userService.save(bizDto);
        return "redirect:" + "/login";
    }
}
